﻿using NUnit.Framework;
using StreetPacMan.Server.Facade;

namespace StreetPacMan.Server.Tests.Integ
{
    [TestFixture]
    public class GhostJoinedAfterPacManJoined : BddBase
    {
        private readonly IServerFacade ServerFacade;
        private readonly JoinGameResult PacMan;
        private readonly JoinGameResult Ghost;

        public GhostJoinedAfterPacManJoined()
        {
            ServerFacade = ServerFacadeFactory.GetServerFacade();
            ServerFacade.CreateGameX("GameName");
            PacMan = ServerFacade.JoinGameX("GameName", "PacManName", PlayerRole.PacMan);
            Ghost = ServerFacade.JoinGameX("GameName", "GhostName", PlayerRole.Ghost);
        }

        [Test]
        public void EntityIdsShouldDiffer()
        {
            Assert.AreNotEqual(Ghost.PlayerId, PacMan.PlayerId);
        }

        [Test]
        public void LastMessageShouldSayGhostJoined()
        {
            Assert.AreEqual("GhostName joined as Ghost", ServerFacade.GetGameStateAsObvserverX("GameName").LastGameMessage);
        }
        [Test]
        public void GameStateShouldBeWaitingForMorePlayersToJoin()
        {
            Assert.AreEqual(GameState.WaitingForMorePlayersToJoin, ServerFacade.GetGameStateAsObvserverX("GameName").State);
        }
    }
}